﻿namespace WMS6.Web.Billing
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class BillingDailyInvQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnSearch;
        protected HtmlForm F9230;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img1;
        protected Label lblBeginDate;
        protected Label lblBillingOrder;
        protected Label lblEndDate;
        protected Label lblMsg;
        protected Label lblOwnerID;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtBeginDate;
        protected TextBox txtEndDate;
        protected TextBox txtOwnerID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("BillingDailyInvList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9230_001");
            }
            else if (string.IsNullOrEmpty(this.txtBeginDate.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F9230_002");
            }
            else
            {
                DateTime dt = new DateTime();
                if (!DateTime.TryParse(this.txtBeginDate.Text.Trim(), out dt))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F9230_007");
                }
                else if (string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F9230_003");
                }
                else
                {
                    dt = new DateTime();
                    if (!DateTime.TryParse(this.txtEndDate.Text.Trim(), out dt))
                    {
                        this.lblMsg.Text = base.GetGlobalMsgResource("F9230_007");
                    }
                    else
                    {
                        base.Server.Transfer("BillingDailyInvList.aspx?action=" + this.hdnActionID.Value, false);
                    }
                }
            }
        }

        private void LoadDDl()
        {
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadDDl();
                this.hdnDataFormat.Value = "yyyy-MM-dd";
            }
        }

        public string BeginDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtBeginDate.Text.Trim()))
                {
                    return Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToString("yyyy-MM-dd");
                }
                return "";
            }
        }

        public string EndDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
                {
                    return Convert.ToDateTime(this.txtEndDate.Text.Trim()).ToString("yyyy-MM-dd");
                }
                return "";
            }
        }

        public string Owner
        {
            get
            {
                return this.txtOwnerID.Text.Trim();
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), "Same As");
                }
                return "";
            }
        }
    }
}

